package com.example.service.impl;

import com.example.demodao.entity.TbItem;
import com.example.service.AbstractCart;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * @author zhang
 */
@Slf4j
@Service(value = "NormalUserCart")
public class NormalUserCart extends AbstractCart {

    @Override  
    protected void processCouponPrice(long userId, TbItem item) {
        log.info("普通用户的购物车:{}，方法用于计算商品折扣",userId);
        item.setCouponPrice(BigDecimal.ZERO);
    }  

    @Override  
    protected void processDeliveryPrice(long userId, TbItem item) {
        log.info("普通用户的购物车:{}，方法用于计算运费。",userId);
        item.setDeliveryPrice(item.getPrice()  
                              .multiply(BigDecimal.valueOf(item.getQuantity()))  
                              .multiply(new BigDecimal("0.1")));  
    }  
}  